"""
    Controller for project defence.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class ProjectDefenceController(LookupController, CRUDController):
    model_object = model.ProjectDefence
    lookup_columns = [
        TableCol(name='group_title', caption=_('Group')),
        TableCol(name='classroom', caption=_('Classroom')),
        TableCol(name='number', caption=_('Number')),
        TableCol(name='date', caption=_('Date')),
        TableCol(name='start_time', caption=_('Start time')),
        TableCol(name='end_time', caption=_('End time'))
        ]

    edit_fields = ['groupID', 'date', 'classroomID', 'number', 'startTime']
    view_fields = edit_fields + ['endTime']

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('project_defence_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = ProjectDefenceController()
